home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1146 / 1146.xpi / chrome / screengrab.jar / content / Grab.js < prev    next >
Text File  |  2009-03-09  |  2KB  |  65 lines

  1. /**
  2.  * @author andy
  3.  */
  4. screengrab.Grab = function(target, capture, action) {
  5.     try {
  6.         target.obtainDimensions(function(browser, dimensions) {
  7.             capture(browser, dimensions, function(canvas) {
  8.                 action.doAction(canvas);
  9.             });
  10.         });
  11.     } catch (error) {
  12.         screengrab.error(error);
  13.     }
  14. }
  15. screengrab.Grab2 = function(targetName, captureName, action) {
  16.     try {
  17.         // bring focus to us
  18.         screengrab.Browser.contentFrame().focus();
  19.         var target = eval("new sg." + targetName + "()");
  20.         var capture = eval("sg." + captureName);
  21.         target.obtainDimensions(function(browser, dimensions) {
  22.             capture(browser, dimensions, function(canvas) {
  23.                 action(canvas);
  24.             });
  25.         });
  26.     } catch (error) {
  27.         screengrab.error(error);
  28.     }
  29. }
  30. screengrab.StagedGrab2 = function() {
  31.     try {
  32.         var choices = {target: null, capture: "CaptureViewPort", action: null};
  33.         window.openDialog("chrome://screengrab/content/TargetChoice.xul", "targetChoice", "centerscreen,modal",
  34.                           {choices: choices});
  35.         choices.target = eval("new sg." + choices.target + "()");
  36.         choices.capture = eval("sg." + choices.capture);
  37.         choices.target.obtainDimensions(function(browser, dimensions) {
  38.             choices.capture(browser, dimensions, function(canvas) {
  39.                 window.openDialog("chrome://screengrab/content/ActionChoice.xul", "actionChoice", "centerscreen,modal",
  40.                                     {choices: choices});
  41.                 choices.action = eval("new sg." + choices.action + "()");
  42.                 choices.action.doAction(canvas);
  43.             });
  44.         });
  45.     } catch (error) {
  46.         screengrab.error(error);
  47.     }
  48. }
  49. screengrab.StagedGrab = function(target, capture) {
  50.     try {
  51.         target.obtainDimensions(function(browser, dimensions) {
  52.             capture(browser, dimensions, function(canvas) {
  53.                 // make sure that the canvas is obtainable via this.opener.canvas...
  54.                 this.canvas = canvas;
  55.                 window.open("chrome://screengrab/content/ActionChoice.xul", "actionChoice", "chrome,centerscreen",
  56.                             {canvas: canvas});
  57.             });
  58.         });
  59.     } catch (error) {
  60.         screengrab.error(error);
  61.     }
  62. }
  63. screengrab.FinishGrab = function(action, canvas) {
  64.     action.doAction(canvas);
  65. }